package core.sql.环境;

import org.apache.spark.SparkContext;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;

import java.util.Arrays;

public class Spark04_MODEL2 {
    public static void main(String[] args) {
        SparkSession sparkSession = SparkSession
                .builder()
                .master("local[*]")
                .appName("Spark04_MODEL2")
                .getOrCreate();
        // 读取 JSON 数据
        Dataset<Row> json = sparkSession.read()
                .option("mode", "PERMISSIVE") // 允许坏记录
                .option("badRecordsPath", "data/bad_records") // 指定错误记录的输出路径
                .json("data/user_sql.json");

        json.select("*").show();


        try {


        } catch (Exception e) {
            e.printStackTrace(); // 捕获并打印异常
        } finally {
            sparkSession.close();
        }
    }
}
